package com.aaa.web.controller.batterymanger;

import com.aaa.entity.BatteryPosition;
import com.aaa.web.commons.BatteryInfoQuery;
import com.aaa.web.commons.Result;
import com.aaa.web.service.batterymangerservice.BatteryMangerBiz;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
import java.util.Map;

/**
 * com.aaa.web.controller.batterymanger class
 *
 * @author Kevin Jia
 * @CLASS:BatteryAdderss
 * @Date:2018/12/19 16:25
 */
@Controller
@RequestMapping("/battery")
public class BatteryAdderss {


    @Autowired
    private BatteryMangerBiz batteryMangerBiz;

    @RequestMapping("/addressMap")
    public String toBatteryAddress() {
        return "views/webhtml/batteryaddress/batterymap";
    }


    @RequestMapping("/addaddress")
    public String toAddAddress() {
        return "views/webhtml/batteryaddress/showadd";
    }

    @RequestMapping("/toaddbatteryinfo")
    public String toAddBatteryInfo() {
        return "views/webhtml/batteryaddress/toAddBatteryAddress";
    }

    /**
     * @Description: 获取充电点坐标
     * @Param:
     * @return:
     * @Author: Kevin Jia
     * @Date: 2018/12/21
     * @Time: 8:46
     */
    @ResponseBody
    @RequestMapping("/getPosition")
    public List<BatteryPosition> getPosition(String lng, String lat) {
        return batteryMangerBiz.getPosition(lng, lat);
    }

    /**
     * @Description: 获取当前地区所有充电点
     * @Param:
     * @return:
     * @Author: Kevin Jia
     * @Date: 2018/12/21
     * @Time: 8:46
     */
    @ResponseBody
    @RequestMapping("/getbatteryinfo")
    public Map getBatteryInfo(BatteryInfoQuery query,BatteryPosition batteryPosition) {
        return batteryMangerBiz.getBatteryInfo(query,batteryPosition);
    }

    @ResponseBody
    @RequestMapping("/getschools")
    public Map getSchools(String school,BatteryInfoQuery query) {

        return batteryMangerBiz.getSchools(school,query);
    }
    /**
     * @Description: 添加
     * @Param: BatteryPosition
     * @return: Map
     * @Author: Kevin Jia
     * @Date: 2018/12/22
     * @Time: 9:37
     */
    @ResponseBody
    @RequestMapping("/addbatteryinfo")
    public Result addBatteryInfo(BatteryPosition batteryPosition) {

        return batteryMangerBiz.InsertBatteryPosition(batteryPosition);
    }
    /**
     * @Description: 修改
     * @Param: BatteryPosition
     * @return: Map
     * @Author: Kevin Jia
     * @Date: 2018/12/22
     * @Time: 9:37
     */
    @ResponseBody
    @RequestMapping("/updatebatteryinfo")
    public Result updateBatteryInfo(BatteryPosition batteryPosition) {

        return batteryMangerBiz.updateBatteryInfo(batteryPosition);
    }

    /**
     * @Description: 假删除
     * @Param:
     * @return:
     * @Author: Kevin Jia
     * @Date: 2018/12/22
     * @Time: 13:53
     */
    @ResponseBody
    @RequestMapping("/delbatteryinfo")
    public Result delBatteryInfo(String id) {

        return batteryMangerBiz.delBatteryInfo(id);
    }
}
